import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2023-06-18
 * Time: 12:51
 */
public class Mystack {

    public boolean IsPopOrder(int [] pushA ,int [] popA){
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushA.length ; i++) {
            stack.push(pushA[i]);
            while (!stack.empty() && j< pushA.length && stack.peek()==popA[j]){
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }


}
